---
title: gluestack-ui VStack Component | Installation, Usage, and API

description: VStack is a layout component for arranging elements vertically.

pageTitle: VStack

pageDescription: VStack is a layout component for arranging elements vertically.

showHeader: true

tag: RSC
---

import { Meta } from '@storybook/addon-docs';

<Meta title="with-nativewind/Components/Layout/VStack" />

import {
  AppProvider,
  CodePreview,
  Table,
  TableContainer,
  Text,
  InlineCode,
  Tabs
} from '@gluestack/design-system';
import { Box, VStack } from '../../core-components/nativewind';
import { transformedCode } from '../../utils';
import Wrapper from '../../core-components/nativewind/Wrapper';
import { CollapsibleCode } from '@gluestack/design-system';

This is an illustration of **VStack** component.

<Wrapper>
  <CodePreview
    showComponentRenderer={ true }
  showArgsController = { true}
  metaData = {{
    code: `
        <Box className='justify-center h-80'>
          <VStack {...props}>
            <Box  className="h-20 w-20 bg-primary-300" />
            <Box  className="h-20 w-20 bg-primary-400" />
            <Box  className="h-20 w-20 bg-primary-500" />
          </VStack>
        </Box>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
        scope: {
      Wrapper,
        VStack,
        Box,
      },
    argsType: {
      space: {
        control: 'select',
          options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'],
          default: 'md',
        },
      reversed: {
        control: 'boolean',
          options: [true, false],
          default: false,
        },
    },
  }
}
/>
</Wrapper>

<br/>

## Installation

<Tabs value="cli" type="section">
  <Tabs.TabList>
      <Tabs.Tab value="cli">
        <Tabs.TabTitle>CLI</Tabs.TabTitle>
      </Tabs.Tab>
     <Tabs.Tab value="manual">
        <Tabs.TabTitle>Manual</Tabs.TabTitle>
     </Tabs.Tab>
  </Tabs.TabList>
  <Tabs.TabPanels>
    <Tabs.TabPanel value="cli">
<>

### Run the following command:
  ```bash
  npx gluestack-ui add vstack
  ```
</>
    </Tabs.TabPanel>
    <Tabs.TabPanel value="manual"> 
<>

### Step 1: Copy and paste the following code into index.tsx in your project.
<CollapsibleCode>

```jsx 
%%-- File: core-components/nativewind/vstack/index.tsx --%% 
```
</CollapsibleCode>

> Note: **Step 2 is optional and only required if you want to add support for [React Server Components](https://vercel.com/blog/understanding-react-server-components), You can skip this and jump to Step 3 directly if you don't have this requirement.**

### Step 2(optional): Copy and paste the following code into index.web.tsx in your project.
<CollapsibleCode>

```jsx 
%%-- File: core-components/nativewind/vstack/index.web.tsx --%% 
```
</CollapsibleCode>

### Step 3: Copy and paste the following code into styles.tsx in your project.
<CollapsibleCode>

```jsx 
%%-- File: core-components/nativewind/vstack/styles.tsx --%% 
```
</CollapsibleCode>

### Step 4: Update the import paths to match your project setup.
</>
    </Tabs.TabPanel>
  </Tabs.TabPanels>
</Tabs>

## API Reference

To use this component in your project, include the following import statement in your file.

```jsx
import { VStack } from '@/components/ui/vstack';
```

```jsx
export default () => <VStack />;
```

### Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

#### VStack

It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component.

### Accessibility

The accessibility of a VStack is primarily determined by the accessibility information of the components it contains. When you pass an accessible component inside a VStack, its accessibility attributes, such as labels and hints, will be utilized by assistive technologies like screen readers.

In essence, the VStack acts as a container that inherits and propagates the accessibility attributes of its child views.

### Props

VStack component is created using View component from react-native. It extends all the props supported by [React Native View](https://reactnative.dev/docs/view#props), [utility props](https://ui.gluestack.io/docs/styling/utility-and-sx-props) and the props mentioned below.

#### VStack

<>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Prop</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Type</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Default</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Description</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>space</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>string</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>-</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`It sets the space between children. By default there is no space between the VStack items.`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>reversed</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>boolean</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>false</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`When true, it places the VStack items in reverse direction.`}</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</>

### Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

#### VStack Reversed

A VStack component with the reversed prop reverses the order of vertically stacked elements, enabling customized vertical layouts and visual arrangements of content within a user interface.

<Wrapper>
  <CodePreview
    _rendererWrapper={{ py: '$2.5' }}
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <VStack space='md'>
          <Box className='w-20 h-20 bg-primary-300' />
          <Box className='w-20 h-20 bg-primary-400' />
          <Box className='w-20 h-20 bg-primary-500' />
        </VStack>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: { Box, Wrapper, VStack },
      argsType: {},
    }}
  />
</Wrapper>
